package com.song.mongo.service.impl;

import com.song.mongo.dao.UserDao;
import com.song.mongo.pojo.User;
import com.song.mongo.service.IUserService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author TonySong
 * @date 2024/5/16 0016
 * @time 16:01
 */
@Service
public class UserService implements IUserService {
    @Resource
    private UserDao userDao;
    @Override
    public List<User> getAllUser() {
        return this.userDao.findAll();
    }
    @Override
    public void addUser(User user) {
       this.userDao.insert(user);
    }
    @Override
    public void deleteUser(String id) {
         this.userDao.deleteById(id);
    }

    @Override
    public void updateUser(User user) {
        this.userDao.save(user);
    }

    @Override
    public User getUserById(String id) {
        return this.userDao.findById(id).get();
    }
}
